Model Function

Input Table
label variable distribution lower upper
Seedling Cost Rice (IDR) seedling_cost_rice posnorm 120000.00 900000.0
Planting Cost Rice (IDR) planting_cost_rice posnorm 60000.00 900000.0
Herbicide Cost Rice (IDR) herbicide_cost_rice posnorm 100000.00 400000.0
Plowing Cost Rice (IDR) plowing_cost_rice posnorm 500000.00 750000.0
Dolomite Cost Rice (IDR) dolomite_cost_rice posnorm 60000.00 375000.0
Land Clearing Rice Cost (IDR) clearing_cost_rice posnorm 120000.00 600000.0
Equipment cost 3 years replacement (IDR) equipment_cost_rice_3 posnorm 290000.00 550000.0
Equipment cost 5 years replacement (IDR) equipment_cost_rice_5 posnorm 720000.00 910000.0
Insecticide Cost Rice (IDR) insecticide_cost_rice posnorm 75000.00 250000.0
Spraying Cost Rice (IDR) spraying_cost_rice posnorm 60000.00 200000.0
Fertilizer Cost (IDR) fertilizer_cost_rice posnorm 650000.00 4250000.0
Fertilizing Cost Rice (IDR) fertilizing_cost_rice posnorm 120000.00 600000.0
Harvesting Cost Rice (IDR) harvesting_cost_rice posnorm 70000.00 600000.0
Packaging Cost Rice (IDR) packaging_cost_rice posnorm 200000.00 300000.0
Milling cost rice (IDR) milling_cost_rice posnorm 900000.00 1800000.0
Rice Production (Kg) rice_production posnorm 1000.00 2000.0
Rice Price (IDR) rice_price posnorm 7000.00 9000.0
Rice Benefit (IDR) rice_benefit posnorm 3500000.00 18000000.0
Life spans (Years) n_years const 25.00 25.0
Discount rate (%) discount_rate posnorm 4.00 15.0
Percentage Rice Risk Occur (%) p_rice_risk_occur tnorm_0_1 0.20 0.6
Percentage Rice Yield Loss (%) p_rice_yield_loss posnorm 0.10 1.0
Transportation cost for monitoring (IDR) transportation_cost posnorm 240000.00 360000.0
Planting Cost Rubber (IDR) planting_cost_rubber posnorm 400000.00 2250000.0
Field Protection (IDR) field_protection_rice posnorm 3140000.00 4400000.0
Dike Construction for rice (IDR) dike_construction_rice posnorm 24000000.00 32000000.0
Percentage Coconut Risk Occur (%) p_coco_risk_occur tnorm_0_1 0.10 0.5
Percentage Coconut Yield Loss (%) p_coco_yield_loss posnorm 0.30 0.7
Time To reach Immature Coconut (Years) immature_coco_est const 4.00 4.0
Time To reach Mature Coconut (Years) mature_coco_est const 8.00 8.0
Maximum Coconut Estimation Yield (Kg) max_coco_harvest posnorm 1500.00 1620.0
Coconut production (Kg) coco_yield posnorm 4000.00 4950.0
Seedling Cost Coconut (IDR) seedling_cost_coco posnorm 400000.00 900000.0
Coconut price (Rp/Pcs) coco_price posnorm 1000.00 5000.0
Percentation Immature Yield Coconut (%) immature_coco_yield_est posnorm 20.00 50.0
Percentation Mature Yield Coconut (%) mature_coco_yield_est posnorm 60.00 80.0
Planting Cost Coconut (IDR) planting_cost_coco posnorm 300000.00 900000.0
Fertilizer Cost Coconut before first harvesting (IDR) fertilizer_cost_coco_pre posnorm 12000.00 75000.0
Fertilizer Cost Coconut after first harvesting (IDR) fertilizer_cost_coco_post posnorm 28000.00 100000.0
Harvesting Cost Coconut (IDR) harvesting_cost_coco posnorm 2400000.00 5400000.0
Percentage Areca (Pinang) Risk Occur (%) p_pinang_risk_occur tnorm_0_1 0.10 0.5
Percentage Areca (Pinang) Yield Loss (%) p_pinang_yield_loss posnorm 0.20 0.7
Time To reach Immature (First Yield) Areca (Pinang) (Years) immature_pn_est const 3.00 3.0
Time To reach Mature Areca (Pinang) (Years) mature_pn_est const 6.00 6.0
Maximum Areca (Pinang) Estimation Yield (Kg) max_pn_harvest posnorm 360.00 400.0
Areca (Pinang) production (kg) pinang_yield posnorm 360.00 400.0
Seedling Cost Areca (IDR) seedling_cost_pinang posnorm 108000.00 200000.0
Areca (Pinang) price (IDR) pinang_price posnorm 10000.00 15000.0
Percentation Immature Yield Areca (Pinang) (%) immature_pn_yield_est posnorm 40.00 60.0
Percentation Mature Yield Areca (Pinang) (%) mature_pn_yield_est posnorm 70.00 80.0
Seedling Cost Areca (Pinang) Mono (IDR) seedling_cost_png posnorm 375000.00 675000.0
Planting Cost Areca (Pinang) (IDR) planting_cost_png posnorm 300000.00 900000.0
Fertilizer Cost Areca (Pinang) before first harvesting (IDR) fertilizer_cost_png_pre posnorm 30000.00 225000.0
Fertilizer Cost Areca (Pinang) Mono after first harvesting (IDR) fertilizer_cost_png_post posnorm 70000.00 300000.0
Harvesting Cost Areca (Pinang) (IDR) harvesting_cost_png posnorm 1200000.00 3600000.0
Areca (Pinang) Production (Kg) png_yield posnorm 1250.00 1350.0
Maximum Areca (Pinang) Estimation Yield (Kg) max_png_harvest posnorm 1250.00 1350.0
Planting Cost Rice (IDR) planting_cost_rice_nfl posnorm 60000.00 600000.0
Fertilizing Cost Rice (IDR) fertilizing_cost_rice_nfl posnorm 60000.00 400000.0
Fertilizing Cost Coconut Areca (IDR) fertilizing_cost_coco_pinang posnorm 60000.00 100000.0
Fertilizing Cost Areca (Pinang) (IDR) fertilizing_cost_png posnorm 60000.00 100000.0
Land Clearing Rice Cost (IDR) clearing_cost_rice_nfl posnorm 120000.00 400000.0
Maize Yield (Kg) maize_yield posnorm 300.00 500.0
Maize Price per Kg (IDR) maize_price posnorm 3500.00 4500.0
Planting, Harvesting and Fertilizer Cost for Maize (IDR) maize_cost posnorm 530000.00 1100000.0
Decay Rate Maize (%) decay_rate_maize posnorm 0.05 0.1
Percentage Risk Maize Occur (%) p_maize_risk_occur tnorm_0_1 0.20 0.6
Percentage Yield Loss Maize (%) p_maize_yield_loss posnorm 0.10 1.0
Cost Variation CV_cost posnorm 10.00 20.0
Areca Price Variation CV_areca_price posnorm 10.00 40.0
Maize Price Variation CV_maize_price posnorm 10.00 30.0
Rice Price Variation CV_rice_price posnorm 10.00 30.0
Coconut Price Variation CV_coco_price posnorm 10.00 30.0
Risk Variation CV_risk posnorm 2.00 12.0
CV Variation var_CV posnorm 20.00 50.0
IDR to USD cur_change const 15141.30 15141.3

Model Function 1 (Rice Monoculture vs Rice-areca nut_catechu-Coconut along the dike)

library(decisionSupport)

first_decision_function <- function(x, varnames) {
  
  # Corresponding to 25 years of simulation
  
  n_years <- 25

  # Define each variable as vectors of 25 values 
  
  # Cost variables
  seedling.cost.rice <- rep(0, n_years)
  land.clearing.rice <- rep(0, n_years)
  herbicide.cost.rice <- rep(0, n_years)
  fertilizer.cost.rice <- rep(0, n_years)
  fertilizing.cost.rice <- rep(0, n_years)
  spraying.cost.rice <- rep(0, n_years)
  dolomite.cost.rice <- rep(0, n_years)
  insecticide.cost.rice <- rep(0, n_years)
  milling.cost.rice <- rep(0, n_years)
  packaging.cost.rice <- rep(0, n_years)
  plowing.cost.rice <- rep(0, n_years)
  planting.cost.rice <- rep(0, n_years)
  harvest.cost.rice <- rep(0, n_years)
  equipment.cost.rice <- rep(0, n_years)
  equipment.cost.rice.5 <- rep(0, n_years)
  equipment.cost.rice.3 <- rep(0, n_years)
  dike.cost.rice <- rep(0, n_years)
  field.protection.rice <- rep(0, n_years)
  
  # Cost variables coco-areca nut (pinang)
  seedling.cost.coco <- rep(0, n_years)
  planting.cost.coco <- rep(0, n_years)
  harvesting.cost.coco.pn <- rep(0, n_years)
  fertilizing.cost.coco.pn <- rep(0, n_years)
  fertilizer.cost.coco <- rep(0, n_years)
  seedling.cost.pn <- rep(0, n_years)
  harvesting.cost.coco.pn <- rep(0, n_years)

  
  # Benefit variables Coco-areca nut
  yield.coco.risk <- rep(0, n_years)
  yield.rice.risk <- rep(0, n_years)
  pn_yield <- rep(0, n_years)
  pn.price <- rep(0, n_years)
  yield.pinang.risk <- rep(0, n_years)
  total_rice_benefit <- rep(0, n_years)
  coco.yield <- rep(0, n_years)
  coco.price <- rep(0, n_years)
  
  
  
  # Simulate the chance for risk events to occur during the simulation period
  coco.risk <- chance_event(chance = p_coco_risk_occur, value_if = 1, n_years)
  pinang.risk <- chance_event(chance = p_pinang_risk_occur, value_if = 1, n_years)
  rice.risk <- chance_event(chance = p_rice_risk_occur,  value_if = 1, n_years)
  maize.risk <- chance_event(chance = p_maize_risk_occur, value_if = 1, n = n_years)
  
  pinang.risk[1:n_years] <- vv(p_pinang_risk_occur, CV_risk, n_years)
  coco.risk[1:n_years] <- vv(p_coco_risk_occur, CV_risk, n_years)
  rice.risk[1:n_years] <- vv(p_rice_risk_occur, CV_risk, n_years)
  
  yield.coco.risk[1:n_years] <- vv(p_coco_yield_loss, CV_risk, n_years)
  yield.pinang.risk[1:n_years] <- vv(p_pinang_yield_loss, CV_risk, n_years)
  yield.rice.risk[1:n_years] <- vv(p_rice_yield_loss, CV_risk, n_years)
  
  ### Calculate system cost of Rice
  
  # Seedling cost rice
  seedling.cost.rice[1:n_years] <- vv(seedling_cost_rice, CV_cost, n_years)
  
  # Land clearing rice
  land.clearing.rice[1:n_years] <- vv(clearing_cost_rice, CV_cost, n_years)
  
  # Herbicide cost rice
  herbicide.cost.rice[1:n_years] <- vv(herbicide_cost_rice, CV_cost, n_years)
  
  # Fertilizer cost rice
  fertilizer.cost.rice[1:n_years] <- vv(fertilizer_cost_rice, CV_cost, n_years)
  
  # Fertilizing cost rice
  fertilizing.cost.rice[1:n_years] <- vv(fertilizing_cost_rice, CV_cost, n_years)
  
  # Spraying insecticide cost rice
  spraying.cost.rice[1:n_years] <- vv(spraying_cost_rice, CV_cost, n_years)
  
  # Planting cost rice
  planting.cost.rice[1:n_years] <- vv(planting_cost_rice, CV_cost, n_years)
  
  # Plowing cost rice
  plowing.cost.rice[1:n_years] <- vv(plowing_cost_rice, CV_cost, n_years)
  
  # Land management Rice
  dolomite.cost.rice[1:n_years] <- vv(dolomite_cost_rice, CV_cost, n_years)
  
  # Spraying insecticide cost rice
  insecticide.cost.rice[1:n_years] <- vv(insecticide_cost_rice, CV_cost, n_years)
  
  # Milling cost rice
  milling.cost.rice[1:n_years] <- vv(milling_cost_rice, CV_cost, n_years)
  
  # Packaging Cost rice
  packaging.cost.rice[1:n_years] <- vv(packaging_cost_rice, CV_cost, n_years)
  
  # Harvesting cost 
  harvest.cost.rice[1:n_years] <- vv(harvesting_cost_rice, CV_cost, n_years)
  
  # Dike cost 
  dike.cost.rice[1] <- vv(dike_construction_rice, CV_cost, 1)
  dike.cost.rice[2:n_years] <- 0
  
  # Field Protection cost using barbed wire
  field.protection.rice[1] <- vv(field_protection_rice, CV_cost, 1)
  field.protection.rice[2:9] <- 0
  field.protection.rice[10] <- vv(field_protection_rice/2, CV_cost, 1)
  field.protection.rice[11:19] <- 0
  field.protection.rice[20] <- vv(field_protection_rice/2, CV_cost, 1)
  field.protection.rice[21:n_years] <- 0
  
  # Equipment cost 3 years replacement
  equipment.cost.rice.3[1] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[2:3] <- 0
  equipment.cost.rice.3[5] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[6:8] <- 0
  equipment.cost.rice.3[9] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[10:12] <- 0
  equipment.cost.rice.3[13] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[14:16] <- 0
  equipment.cost.rice.3[17] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[18:20] <- 0
  equipment.cost.rice.3[21] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[22:24] <- 0
  equipment.cost.rice.3[25] <- vv(equipment_cost_rice_3, CV_cost, 1)
  
  # Equipment cost 5 years replacement
  equipment.cost.rice.5[1] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[2:6] <- 0
  equipment.cost.rice.5[7] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[8:12] <- 0
  equipment.cost.rice.5[13] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[14:18] <- 0
  equipment.cost.rice.5[19] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[20:24] <- 0
  equipment.cost.rice.5[25] <- vv(equipment_cost_rice_5, CV_cost, 1)
  
  equipment.cost.rice <- equipment.cost.rice.5 + equipment.cost.rice.3
  
  
  # Calculate system benefit of Rice
  
  rice.yield.risk <- vv(rice_production*(1-rice.risk*yield.rice.risk), CV_risk, n_years)
  
  tot_rice_benefit <- vv(rice.yield.risk * rice_price, CV_rice_price, n_years)
  
  # Calculate NPV of rice
  
  
  # Total Benefit Rice (Family Labour and Non Family Labour are included using shadow price)
  total_rice_benefit <- ((tot_rice_benefit - seedling.cost.rice - land.clearing.rice - 
                        herbicide.cost.rice - fertilizer.cost.rice - harvest.cost.rice - 
                        planting.cost.rice - plowing.cost.rice - equipment.cost.rice - 
                        dolomite.cost.rice - insecticide.cost.rice - milling.cost.rice - 
                        packaging.cost.rice - fertilizing.cost.rice - spraying.cost.rice - field.protection.rice)*2)/cur_change
  
  # Calculate rice agroforestry
    
  # Coco yield 
  seedling.cost.coco[1] <- vv(seedling_cost_coco, CV_cost, 1)
  seedling.cost.coco[2:n_years] <- 0
  
  # Fertilizer cost coco
  fertilizer.cost.coco[1:4] <- vv(fertilizer_cost_coco_pre, CV_cost, 4)
  fertilizer.cost.coco[5:n_years] <- vv(fertilizer_cost_coco_post, CV_cost, n_years - 4)
  
  # Fertilizing cost coco pinang
  fertilizing.cost.coco.pn[1:4] <- vv(fertilizing_cost_coco_pinang, CV_cost, 4)
  fertilizing.cost.coco.pn[5:n_years] <- vv(fertilizing_cost_coco_pinang, CV_cost, n_years - 4)

  # Planting cost coco
  planting.cost.coco[1] <- vv(planting_cost_coco, CV_cost, 1)
  planting.cost.coco[2:n_years] <- 0
  
  # Harvesting cost coco pinang
  harvesting.cost.coco.pn[1:3] <- 0
  harvesting.cost.coco.pn[4:n_years] <- vv(harvesting_cost_coco, CV_cost, n_years - 3)
  
  # Coco Price
  coco.price[1:n_years] <- vv(coco_price, CV_coco_price, n_years)
  
  
  cc_yield <- gompertz_yield(max_harvest = max_coco_harvest, 
                            time_to_first_yield_estimate = immature_coco_est, 
                            time_to_second_yield_estimate = mature_coco_est,
                            first_yield_estimate_percent = immature_coco_yield_est,
                            second_yield_estimate_percent = mature_coco_yield_est,
                            n_years = n_years, 
                            var_CV = 0, 
                            no_yield_before_first_estimate = TRUE)
  
  cc_yield_risk <- cc_yield*(1-coco.risk*yield.coco.risk)
  
  tot_cc_benefit <- cc_yield_risk * coco.price
  
  # Calculate Pinang System
  
  # seedling cost pinang
  
  seedling.cost.pn[1] <- vv(seedling_cost_pinang, CV_cost, 1)
  seedling.cost.pn[2:n_years] <- 0
  
  # Pinang Price
  pn.price[1:n_years] <- vv(pinang_price, CV_areca_price, n_years)
  
  # pinang yield
  pn_yield <- gompertz_yield(max_harvest = max_pn_harvest, 
                            time_to_first_yield_estimate = immature_pn_est, 
                            time_to_second_yield_estimate = mature_pn_est,
                            first_yield_estimate_percent = immature_pn_yield_est,
                            second_yield_estimate_percent = mature_pn_yield_est,
                            n_years = n_years, 
                            var_CV = 0, 
                            no_yield_before_first_estimate = TRUE)
  
  pn_yield_risk <- pn_yield*(1-pinang.risk*yield.pinang.risk)
  
  tot_pn_benefit <- pn_yield_risk * pn.price
  
  # Maize along the dike
  
  time <- 1:n_years
  decay_speed_maize <- -log(1-decay_rate_maize)
  AF_maize <- maize_yield*exp(-decay_speed_maize*(time-1))
  tot_AF_maize <- vv(maize_yield*(1-maize.risk*p_rice_yield_loss), CV_risk, n_years)
  AF_maize_revenue <- (tot_AF_maize*vv(maize_price, CV_maize_price, n_years))
  
  AF_maize_costs <- vv(maize_cost, CV_cost, n_years)
  
  AF_maize_benefit <- (AF_maize_revenue-AF_maize_costs)*2
  
  
  # Calculate NPV of rice agro forestry (coco pinang)
  
  # Total Benefit Coco-areca nut (Family Labour and Non Family Labour are included using shadow price)
  total_rice_ccpn_benefit <- ((total_rice_benefit + tot_cc_benefit  + tot_pn_benefit + AF_maize_benefit) - 
                              seedling.cost.coco - dike.cost.rice - field.protection.rice - 
                              planting.cost.coco - harvesting.cost.coco.pn  - fertilizer.cost.coco 
                              - seedling.cost.pn - fertilizing.cost.coco.pn)/cur_change
  
  
  # NPV comparison
  
  # NPV Rice- Coco-areca nut (Family Labour and Non Family Labour are included using shadow price)
  NPV_rice_ccpn <- discount(total_rice_ccpn_benefit, discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # NPV Rice (Family Labour and Non Family Labour are included using shadow price)
  NPV_rice <- discount(total_rice_benefit, discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # Benefit of choosing rice Coco-areca nut with dike over Rice Mono without dike
  
  tradeoff_benefit <- NPV_rice_ccpn - NPV_rice
  
  # Final NPV of the decision to choose Rice-Coco-areca nut with dike and field protection over Rice Mono
  
  NPV_tradeoff <- discount(tradeoff_benefit, discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # In the return list, one can indicate any outcome they wish to see from the model
  return(list(trade_off = NPV_tradeoff,
              rice_ccpn_NPV = NPV_rice_ccpn,
              rice_NPV = NPV_rice,
              Cash_Flow_Rice = total_rice_benefit,
              Cash_Flow_Rice_Pinang_Coco = total_rice_ccpn_benefit))
}

Model Function 2 (Rice Monoculture vs Rice-Areca nut along the dike)

library(decisionSupport)

second_decision_function <- function(x, varnames) {
  
  # Corresponding to 25 years of simulation
  
  n_years <- 25

  # Define each variable as vectors of 25 values 
  
  # Cost variables rice
  seedling.cost.rice <- rep(0, n_years)
  land.clearing.rice <- rep(0, n_years)
  herbicide.cost.rice <- rep(0, n_years)
  fertilizer.cost.rice <- rep(0, n_years)
  fertilizing.cost.rice <- rep(0, n_years)
  spraying.cost.rice <- rep(0, n_years)
  dolomite.cost.rice <- rep(0, n_years)
  insecticide.cost.rice <- rep(0, n_years)
  milling.cost.rice <- rep(0, n_years)
  packaging.cost.rice <- rep(0, n_years)
  plowing.cost.rice <- rep(0, n_years)
  planting.cost.rice <- rep(0, n_years)
  harvest.cost.rice <- rep(0, n_years)
  equipment.cost.rice <- rep(0, n_years)
  equipment.cost.rice.5 <- rep(0, n_years)
  equipment.cost.rice.3 <- rep(0, n_years)
  dike.cost.rice <- rep(0, n_years)
  field.protection.rice <- rep(0, n_years)
  
  # Benefit variables
  total_rice_benefit <- rep(0, n_years)
  yield.rice.risk <- rep(0, n_years)
  
  # Cost variable areca nut (pinang)
  seedling.cost.png <- rep(0, n_years)
  planting.cost.png <- rep(0, n_years)
  harvesting.cost.png <- rep(0, n_years)
  fertilizing.cost.png <- rep(0, n_years)
  fertilizer.cost.png <- rep(0, n_years)
  
  # Benefit variables areca nut c (Pinang)
  png_yield <- rep(0, n_years)
  pn.price <- rep(0, n_years)
  yield.pinang.risk <- rep(0, n_years)
  
  
  # Simulate the chance for risk events to occur during the simulation period
  
  pinang.risk <- chance_event(chance = p_pinang_risk_occur, value_if = 1, n_years)
  rice.risk <- chance_event(chance = p_rice_risk_occur,  value_if = 1, n_years)
  maize.risk <- chance_event(chance = p_maize_risk_occur, value_if = 1, n = n_years)
  
  
  pinang.risk[1:n_years] <- vv(p_pinang_risk_occur, CV_risk, n_years)
  rice.risk[1:n_years] <- vv(p_rice_risk_occur, CV_risk, n_years)
  
  yield.pinang.risk[1:n_years] <- vv(p_pinang_yield_loss, CV_risk, n_years)
  yield.rice.risk[1:n_years] <- vv(p_rice_yield_loss, CV_risk, n_years)
  
  ### Calculate system cost of Rice
  # Seedling cost rice
  seedling.cost.rice[1:n_years] <- vv(seedling_cost_rice, CV_cost, n_years)
  
  # Land clearing rice
  land.clearing.rice[1:n_years] <- vv(clearing_cost_rice, CV_cost, n_years)
  
  # Herbicide cost rice
  herbicide.cost.rice[1:n_years] <- vv(herbicide_cost_rice, CV_cost, n_years)
  
  # Fertilizer cost rice
  fertilizer.cost.rice[1:n_years] <- vv(fertilizer_cost_rice, CV_cost, n_years)
  
  # Fertilizing cost rice
  fertilizing.cost.rice[1:n_years] <- vv(fertilizing_cost_rice, CV_cost, n_years)
  
  # Spraying cost rice
  spraying.cost.rice[1:n_years] <- vv(spraying_cost_rice, CV_cost, n_years)
  
  # Planting cost rice
  planting.cost.rice[1:n_years] <- vv(planting_cost_rice, CV_cost, n_years)
  
  # Plowing cost rice
  plowing.cost.rice[1:n_years] <- vv(plowing_cost_rice, CV_cost, n_years)
  
  # Land management Rice
  dolomite.cost.rice[1:n_years] <- vv(dolomite_cost_rice, CV_cost, n_years)
  
  # Spraying insecticide cost rice
  insecticide.cost.rice[1:n_years] <- vv(insecticide_cost_rice, CV_cost, n_years)
  
  # Milling cost rice
  milling.cost.rice[1:n_years] <- vv(milling_cost_rice, CV_cost, n_years)
  
  # Packaging Cost rice
  packaging.cost.rice[1:n_years] <- vv(packaging_cost_rice, CV_cost, n_years)
  
  # Harvesting cost 
  harvest.cost.rice[1:n_years] <- vv(harvesting_cost_rice, CV_cost, n_years)
  
  # Dike cost 
  dike.cost.rice[1] <- vv(dike_construction_rice, CV_cost, 1)
  dike.cost.rice[2:n_years] <- 0
  
  # Field Protection cost 
  field.protection.rice[1] <- vv(field_protection_rice, CV_cost, 1)
  field.protection.rice[2:9] <- 0
  field.protection.rice[10] <- vv(field_protection_rice/2, CV_cost, 1)
  field.protection.rice[11:19] <- 0
  field.protection.rice[20] <- vv(field_protection_rice/2, CV_cost, 1)
  field.protection.rice[21:n_years] <- 0
  
  # Equipment cost 3 years replacement
  equipment.cost.rice.3[1] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[2:3] <- 0
  equipment.cost.rice.3[5] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[6:8] <- 0
  equipment.cost.rice.3[9] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[10:12] <- 0
  equipment.cost.rice.3[13] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[14:16] <- 0
  equipment.cost.rice.3[17] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[18:20] <- 0
  equipment.cost.rice.3[21] <- vv(equipment_cost_rice_3, CV_cost, 1)
  equipment.cost.rice.3[22:24] <- 0
  equipment.cost.rice.3[25] <- vv(equipment_cost_rice_3, CV_cost, 1)
  
  # Equipment cost 5 years replacement
  equipment.cost.rice.5[1] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[2:6] <- 0
  equipment.cost.rice.5[7] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[8:12] <- 0
  equipment.cost.rice.5[13] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[14:18] <- 0
  equipment.cost.rice.5[19] <- vv(equipment_cost_rice_5, CV_cost, 1)
  equipment.cost.rice.5[20:24] <- 0
  equipment.cost.rice.5[25] <- vv(equipment_cost_rice_5, CV_cost, 1)
  
  equipment.cost.rice <- equipment.cost.rice.5 + equipment.cost.rice.3
  
  
  # Calculate system benefit of Rice
  
  rice.yield.risk <- vv(rice_production*(1-rice.risk*yield.rice.risk), CV_risk, n_years)
  
  tot_rice_benefit <- vv(rice.yield.risk * rice_price, CV_rice_price, n_years)
  
  # Calculate NPV of rice
  
  # Total Benefit Rice (Family Labour and Non Family Labour are included using shadow price)
  total_rice_benefit <- ((tot_rice_benefit - seedling.cost.rice - land.clearing.rice - 
                        herbicide.cost.rice - fertilizer.cost.rice - harvest.cost.rice - 
                        planting.cost.rice - plowing.cost.rice - equipment.cost.rice - 
                        dolomite.cost.rice - insecticide.cost.rice - milling.cost.rice - 
                        packaging.cost.rice - fertilizing.cost.rice - spraying.cost.rice - field.protection.rice)*2)/cur_change

  
  # Calculate rice agroforestry
  
  # Pinang cost
  
  seedling.cost.png[1] <- vv(seedling_cost_png, CV_cost, 1)
  seedling.cost.png[2:n_years] <- 0
  
  # Fertilizer cost pinang
  fertilizer.cost.png[1:3] <- vv(fertilizer_cost_png_pre, CV_cost, 3)
  fertilizer.cost.png[4:n_years] <- vv(fertilizer_cost_png_post, CV_cost, n_years - 3)
  
  # Fertilizing cost pinang
  fertilizing.cost.png[1:3] <- vv(fertilizing_cost_png, CV_cost, 3)
  fertilizing.cost.png[4:n_years] <- vv(fertilizing_cost_png, CV_cost, n_years - 3)
  
  # Planting cost pinang
  planting.cost.png[1] <- vv(planting_cost_png, CV_cost, 1)
  planting.cost.png[2:n_years] <- 0
  
  # Harvesting cost Areca nut
  harvesting.cost.png[1:3] <- 0
  harvesting.cost.png[4:n_years] <- vv(harvesting_cost_png, CV_cost, n_years - 3)
  
  
  # Areca nut Price
  pn.price[1:n_years] <- vv(pinang_price, CV_cost, n_years)
  
  
  png_yield <- gompertz_yield(max_harvest = max_png_harvest, 
                            time_to_first_yield_estimate = immature_pn_est, 
                            time_to_second_yield_estimate = mature_pn_est,
                            first_yield_estimate_percent = immature_pn_yield_est,
                            second_yield_estimate_percent = mature_pn_yield_est,
                            n_years = n_years, 
                            var_CV = 0, 
                            no_yield_before_first_estimate = TRUE)
  
  png_yield_risk <- png_yield*(1-pinang.risk*yield.pinang.risk)
  
  tot_png_benefit <- png_yield_risk * pn.price
  
  time <- 1:n_years
  decay_speed_maize <- -log(1-decay_rate_maize)
  AF_maize <- maize_yield*exp(-decay_speed_maize*(time-1))
  tot_AF_maize <- vv(maize_yield*(1-maize.risk*p_rice_yield_loss), CV_risk, n_years)
  AF_maize_revenue <- (tot_AF_maize*vv(maize_price, CV_maize_price, n_years))
  
  AF_maize_costs <- vv(maize_cost, CV_cost, n_years)
  
  AF_maize_benefit <- (AF_maize_revenue-AF_maize_costs)*2
  
  # Calculate NPV of rice agro forestry
  
  # Total Benefit Rice-areca nut (Family Labour and Non Family Labour are included using shadow price)
  total_rice_pn_benefit <- (total_rice_benefit + tot_png_benefit + AF_maize_benefit - dike.cost.rice - 
                            field.protection.rice - planting.cost.png - harvesting.cost.png - fertilizer.cost.png - 
                            seedling.cost.png - fertilizing.cost.png)/cur_change

  # NPV comparison
  
  # NPV Rice-Areca nut (Family Labour and Non Family Labour are included using shadow price)
  NPV_rice_pn <- discount(total_rice_pn_benefit, 
                          discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # NPV Rice (Family Labour and Non Family Labour are included using shadow price)
  NPV_rice <- discount(total_rice_benefit, 
                       discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # Benefit of choosing rice pinang with dike over rice without dike
  
  # Benefit of choosing rice-areca nut with dike over Rice Mono without dike
  tradeoff_benefit <- NPV_rice_pn - NPV_rice
  
  # Final NPV of the decision to choose Rice-Areca over Rice Mono
  
  # Final NPV of the decision to choose Rice-Areca with dike and field protection over Rice Mono
  NPV_tradeoff <- discount(tradeoff_benefit, 
                           discount_rate = discount_rate, calculate_NPV = TRUE)
  
  # In the return list, one can indicate any outcome they wish to see from the model
  return(list(trade_off = NPV_tradeoff,
              rice_pn_NPV = NPV_rice_pn,
              rice_NPV = NPV_rice,
              Cash_Flow_Rice = total_rice_benefit,
              Cash_Flow_Rice_Pinang = total_rice_pn_benefit))
}

Monte Carlo Simulation

After the model function has been created, it is continued to the function “mCSimulation” from the decision Support Package. The simulation is run a total of 10000 times.

library(decisionSupport)

# Read the estimates from the CSV file
estimate <- estimate_read_csv("Rice_coco_pinang_dike - fix - Copy.csv")

# Perform the Monte Carlo simulation 1
mcSimulation_result1 <- mcSimulation(estimate = estimate,
                                     model_function = first_decision_function,
                                     numberOfModelRuns = 10000,
                                     functionSyntax = "plainNames")

# Perform the Monte Carlo simulation 2
mcSimulation_result2 <- mcSimulation(estimate = estimate,
                                     model_function = second_decision_function,
                                     numberOfModelRuns = 10000,
                                     functionSyntax = "plainNames")

Cashflow

plot_cashflow(mcSimulation_object = mcSimulation_result1,
              color_25_75 = "darkolivegreen4",
              color_5_95 = "darkolivegreen1",
              color_median = "blue",
              cashflow_var_name = "Cash_Flow_Rice_Pinang_Coco")
**Graph. 1 Cashflow Rice-Coco-areca nut**

Graph. 1 Cashflow Rice-Coco-areca nut

**Fig. 2. areca nut along the dike**

Fig. 2. areca nut along the dike

plot_cashflow(mcSimulation_object = mcSimulation_result2,
              color_25_75 = "lightgoldenrod3",
              color_5_95 = "lightgoldenrod1",
              color_median = "blue",
              cashflow_var_name = "Cash_Flow_Rice_Pinang")
**Graph. 2 Cashflow Rice-areca nut**

Graph. 2 Cashflow Rice-areca nut

plot_cashflow(mcSimulation_object = mcSimulation_result1, 
              color_25_75 = "grey60",
              color_5_95 = "grey80",
              color_median = "blue",
              cashflow_var_name = "Cash_Flow_Rice")
**Graph 3. Cashflow Rice Mono**

Graph 3. Cashflow Rice Mono

Comparisson

decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_result1, 
                                    vars = c("rice_ccpn_NPV", "rice_NPV"),
                                    method = 'smooth_simple_overlay', 
                                    bins = 150,
                                    old_names = NULL,
                                    new_names = NULL,
                                    colors = c("greenyellow", "darkgreen"),
                                    outlier_shape = ".",
                                    x_axis_name = "Outcome distribution",
                                    y_axis_name = "frequency",
                                    base_size = 11)
**Graph. 4 NPV comparison Rice Coco areca nut and Rice Mono**

Graph. 4 NPV comparison Rice Coco areca nut and Rice Mono

decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_result2, 
                                    vars = c("rice_pn_NPV", "rice_NPV"),
                                    method = 'smooth_simple_overlay', 
                                    bins = 150,
                                    old_names = NULL,
                                    new_names = NULL,
                                    colors = c("darkgreen","darkgoldenrod3"),
                                    outlier_shape = ".",
                                    x_axis_name = "Outcome distribution",
                                    y_axis_name = "frequency",
                                    base_size = 11)
**Graph. 5 NPV comparison Rice areca nut and Rice Mono**

Graph. 5 NPV comparison Rice areca nut and Rice Mono

decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_result1, 
                                    vars = "trade_off",
                                    old_names = "trade_off",
                                    new_names = "Tradeoff",
                                    method = 'boxplot',
                                    colors = "greenyellow",
                                    outlier_shape = 3)
**Graph. 6 Tradeoff Rice Coco areca nut over Rice Mono**

Graph. 6 Tradeoff Rice Coco areca nut over Rice Mono

decisionSupport::plot_distributions(mcSimulation_object = mcSimulation_result2, 
                                    vars = "trade_off",
                                    method = 'boxplot',
                                    old_names = "trade_off",
                                    new_names = "Tradeoff",
                                    colors = "khaki2",
                                    outlier_shape = 3)
**Graph. 7 Tradeoff Rice areca nut over Rice Mono**

Graph. 7 Tradeoff Rice areca nut over Rice Mono

Variable Importance in Projection (VIP)

pls_result <- plsr.mcSimulation(object = mcSimulation_result1,
                                resultName = names(mcSimulation_result1$y)[4], ncomp = 1)
VIP1 <-plot_pls(pls_result, input_table = mod, threshold = 1, base_size = 14)
VIP1

pls_result2 <- plsr.mcSimulation(object = mcSimulation_result2,
                                 resultName = names(mcSimulation_result2$y)[4], ncomp = 1)
VIP2 <-plot_pls(pls_result2, input_table = mod, threshold = 1, base_size = 14)
VIP2

print(summary(mcSimulation_result1, probs=c(0.05,0.50,0.95)))
## Call:
## mcSimulation(estimate = estimate, model_function = first_decision_function, 
##     numberOfModelRuns = 10000, functionSyntax = "plainNames")
## 
## Summary of Monte Carlo simulation:
##                                       5%       50%     95%     mean chance_loss
## y.trade_off                    -9420.582 -2046.538  4575.9 -2197.89      0.6983
## y.rice_ccpn_NPV                -2075.924  -371.987  2303.1  -200.26      0.6228
## y.rice_NPV                     -4488.256  1687.169  9475.3  1997.63      0.3305
## y.Cash_Flow_Rice1              -1118.189  -417.106   477.0  -382.54      0.7968
## y.Cash_Flow_Rice2               -454.447   251.880  1120.1   283.45      0.2896
## y.Cash_Flow_Rice3               -442.442   244.009  1138.3   280.49      0.2940
## y.Cash_Flow_Rice4               -438.884   245.813  1132.3   285.36      0.2905
## y.Cash_Flow_Rice5               -501.583   193.218  1062.3   227.23      0.3332
## y.Cash_Flow_Rice6               -441.371   244.103  1152.2   287.33      0.2886
## y.Cash_Flow_Rice7               -539.689   139.013  1026.1   177.86      0.3774
## y.Cash_Flow_Rice8               -435.290   248.985  1145.3   285.40      0.2906
## y.Cash_Flow_Rice9               -507.896   186.129  1093.5   224.14      0.3423
## y.Cash_Flow_Rice10              -687.818     1.104   894.0    36.75      0.4983
## y.Cash_Flow_Rice11              -435.769   244.083  1141.8   284.32      0.2954
## y.Cash_Flow_Rice12              -439.818   243.608  1149.1   284.66      0.2891
## y.Cash_Flow_Rice13              -609.118    83.749   959.8   119.83      0.4285
## y.Cash_Flow_Rice14              -432.123   249.246  1135.3   284.21      0.2902
## y.Cash_Flow_Rice15              -421.861   248.942  1128.9   286.30      0.2894
## y.Cash_Flow_Rice16              -417.757   241.197  1126.3   283.31      0.2945
## y.Cash_Flow_Rice17              -497.191   196.410  1077.8   228.99      0.3359
## y.Cash_Flow_Rice18              -428.034   244.361  1139.2   286.22      0.2883
## y.Cash_Flow_Rice19              -546.327   138.702  1025.9   177.47      0.3781
## y.Cash_Flow_Rice20              -700.238    -6.621   894.1    31.96      0.5042
## y.Cash_Flow_Rice21              -496.958   186.451  1045.0   224.26      0.3347
## y.Cash_Flow_Rice22              -433.559   246.931  1120.7   284.80      0.2896
## y.Cash_Flow_Rice23              -430.034   240.079  1140.5   280.69      0.2944
## y.Cash_Flow_Rice24              -425.968   248.992  1127.6   285.99      0.2879
## y.Cash_Flow_Rice25              -590.635    82.341   979.4   122.84      0.4293
## y.Cash_Flow_Rice_Pinang_Coco1  -2714.492 -2124.549 -1598.5 -2137.27      1.0000
## y.Cash_Flow_Rice_Pinang_Coco2    -97.604    54.299   190.9    51.13      0.2772
## y.Cash_Flow_Rice_Pinang_Coco3     25.176   189.578   348.5   188.23      0.0278
## y.Cash_Flow_Rice_Pinang_Coco4   -175.314    50.494   273.1    49.77      0.3568
## y.Cash_Flow_Rice_Pinang_Coco5   -131.899    95.509   326.5    96.63      0.2451
## y.Cash_Flow_Rice_Pinang_Coco6   -106.464   136.080   383.4   136.78      0.1801
## y.Cash_Flow_Rice_Pinang_Coco7    -78.918   175.641   431.2   175.08      0.1286
## y.Cash_Flow_Rice_Pinang_Coco8    -54.596   203.887   481.0   206.67      0.0964
## y.Cash_Flow_Rice_Pinang_Coco9    -37.027   226.280   514.8   230.03      0.0791
## y.Cash_Flow_Rice_Pinang_Coco10  -152.245   122.089   411.5   124.46      0.2353
## y.Cash_Flow_Rice_Pinang_Coco11   -11.441   260.372   560.3   265.07      0.0592
## y.Cash_Flow_Rice_Pinang_Coco12    -4.019   272.000   575.2   276.07      0.0522
## y.Cash_Flow_Rice_Pinang_Coco13    -1.984   284.070   590.5   287.01      0.0515
## y.Cash_Flow_Rice_Pinang_Coco14     1.061   289.067   598.3   293.94      0.0490
## y.Cash_Flow_Rice_Pinang_Coco15    13.450   295.203   608.5   301.67      0.0427
## y.Cash_Flow_Rice_Pinang_Coco16     7.863   300.872   619.9   305.45      0.0457
## y.Cash_Flow_Rice_Pinang_Coco17    13.346   303.077   624.4   308.41      0.0417
## y.Cash_Flow_Rice_Pinang_Coco18    18.757   303.253   614.8   309.34      0.0394
## y.Cash_Flow_Rice_Pinang_Coco19    17.704   305.449   632.6   314.15      0.0411
## y.Cash_Flow_Rice_Pinang_Coco20  -109.115   186.688   503.2   189.97      0.1542
## y.Cash_Flow_Rice_Pinang_Coco21    17.147   311.165   629.7   316.93      0.0410
## y.Cash_Flow_Rice_Pinang_Coco22    25.310   310.477   635.8   317.22      0.0382
## y.Cash_Flow_Rice_Pinang_Coco23    14.527   313.301   627.5   318.35      0.0409
## y.Cash_Flow_Rice_Pinang_Coco24    19.573   315.265   640.1   319.78      0.0392
## y.Cash_Flow_Rice_Pinang_Coco25    19.232   312.307   632.1   318.69      0.0399
##                                chance_zero chance_gain
## y.trade_off                              0      0.3017
## y.rice_ccpn_NPV                          0      0.3772
## y.rice_NPV                               0      0.6695
## y.Cash_Flow_Rice1                        0      0.2032
## y.Cash_Flow_Rice2                        0      0.7104
## y.Cash_Flow_Rice3                        0      0.7060
## y.Cash_Flow_Rice4                        0      0.7095
## y.Cash_Flow_Rice5                        0      0.6668
## y.Cash_Flow_Rice6                        0      0.7114
## y.Cash_Flow_Rice7                        0      0.6226
## y.Cash_Flow_Rice8                        0      0.7094
## y.Cash_Flow_Rice9                        0      0.6577
## y.Cash_Flow_Rice10                       0      0.5017
## y.Cash_Flow_Rice11                       0      0.7046
## y.Cash_Flow_Rice12                       0      0.7109
## y.Cash_Flow_Rice13                       0      0.5715
## y.Cash_Flow_Rice14                       0      0.7098
## y.Cash_Flow_Rice15                       0      0.7106
## y.Cash_Flow_Rice16                       0      0.7055
## y.Cash_Flow_Rice17                       0      0.6641
## y.Cash_Flow_Rice18                       0      0.7117
## y.Cash_Flow_Rice19                       0      0.6219
## y.Cash_Flow_Rice20                       0      0.4958
## y.Cash_Flow_Rice21                       0      0.6653
## y.Cash_Flow_Rice22                       0      0.7104
## y.Cash_Flow_Rice23                       0      0.7056
## y.Cash_Flow_Rice24                       0      0.7121
## y.Cash_Flow_Rice25                       0      0.5707
## y.Cash_Flow_Rice_Pinang_Coco1            0      0.0000
## y.Cash_Flow_Rice_Pinang_Coco2            0      0.7228
## y.Cash_Flow_Rice_Pinang_Coco3            0      0.9722
## y.Cash_Flow_Rice_Pinang_Coco4            0      0.6432
## y.Cash_Flow_Rice_Pinang_Coco5            0      0.7549
## y.Cash_Flow_Rice_Pinang_Coco6            0      0.8199
## y.Cash_Flow_Rice_Pinang_Coco7            0      0.8714
## y.Cash_Flow_Rice_Pinang_Coco8            0      0.9036
## y.Cash_Flow_Rice_Pinang_Coco9            0      0.9209
## y.Cash_Flow_Rice_Pinang_Coco10           0      0.7647
## y.Cash_Flow_Rice_Pinang_Coco11           0      0.9408
## y.Cash_Flow_Rice_Pinang_Coco12           0      0.9478
## y.Cash_Flow_Rice_Pinang_Coco13           0      0.9485
## y.Cash_Flow_Rice_Pinang_Coco14           0      0.9510
## y.Cash_Flow_Rice_Pinang_Coco15           0      0.9573
## y.Cash_Flow_Rice_Pinang_Coco16           0      0.9543
## y.Cash_Flow_Rice_Pinang_Coco17           0      0.9583
## y.Cash_Flow_Rice_Pinang_Coco18           0      0.9606
## y.Cash_Flow_Rice_Pinang_Coco19           0      0.9589
## y.Cash_Flow_Rice_Pinang_Coco20           0      0.8458
## y.Cash_Flow_Rice_Pinang_Coco21           0      0.9590
## y.Cash_Flow_Rice_Pinang_Coco22           0      0.9618
## y.Cash_Flow_Rice_Pinang_Coco23           0      0.9591
## y.Cash_Flow_Rice_Pinang_Coco24           0      0.9608
## y.Cash_Flow_Rice_Pinang_Coco25           0      0.9601
print(summary(mcSimulation_result2, probs=c(0.05,0.50,0.95)))
## Call:
## mcSimulation(estimate = estimate, model_function = second_decision_function, 
##     numberOfModelRuns = 10000, functionSyntax = "plainNames")
## 
## Summary of Monte Carlo simulation:
##                                5%       50%     95%     mean chance_loss
## y.trade_off               -5271.3  1712.829  9809.4  1911.14      0.3374
## y.rice_pn_NPV               796.0  3415.521  8547.3  3865.97      0.0111
## y.rice_NPV                -4801.5  1703.040  9479.4  1954.83      0.3301
## y.Cash_Flow_Rice1         -1119.3  -420.795   477.9  -386.87      0.8003
## y.Cash_Flow_Rice2          -448.6   247.597  1123.2   281.46      0.2865
## y.Cash_Flow_Rice3          -438.2   239.107  1110.0   276.87      0.2943
## y.Cash_Flow_Rice4          -441.2   245.144  1131.1   281.72      0.2916
## y.Cash_Flow_Rice5          -498.0   189.431  1082.6   229.93      0.3378
## y.Cash_Flow_Rice6          -443.7   240.489  1136.4   280.32      0.2948
## y.Cash_Flow_Rice7          -559.4   123.224  1015.8   168.51      0.3879
## y.Cash_Flow_Rice8          -449.7   249.694  1112.7   277.75      0.2909
## y.Cash_Flow_Rice9          -493.9   189.562  1094.6   226.94      0.3424
## y.Cash_Flow_Rice10         -702.6    -8.915   873.5    27.47      0.5072
## y.Cash_Flow_Rice11         -429.3   241.429  1116.1   278.87      0.2943
## y.Cash_Flow_Rice12         -431.3   243.489  1115.3   280.70      0.2944
## y.Cash_Flow_Rice13         -616.7    85.643   954.6   114.92      0.4251
## y.Cash_Flow_Rice14         -444.4   238.490  1127.5   279.78      0.2949
## y.Cash_Flow_Rice15         -457.4   238.769  1143.5   279.46      0.3006
## y.Cash_Flow_Rice16         -446.8   235.793  1155.7   285.08      0.2912
## y.Cash_Flow_Rice17         -495.4   184.957  1076.1   226.83      0.3370
## y.Cash_Flow_Rice18         -442.9   248.263  1127.9   284.96      0.2876
## y.Cash_Flow_Rice19         -558.2   133.914  1020.3   172.26      0.3824
## y.Cash_Flow_Rice20         -699.3    -1.035   890.9    30.49      0.5008
## y.Cash_Flow_Rice21         -504.8   192.593  1081.6   225.88      0.3348
## y.Cash_Flow_Rice22         -453.3   243.993  1130.5   281.90      0.2905
## y.Cash_Flow_Rice23         -440.3   241.367  1128.3   280.09      0.2974
## y.Cash_Flow_Rice24         -447.8   247.877  1112.1   278.05      0.2908
## y.Cash_Flow_Rice25         -609.2    82.373   972.7   120.80      0.4318
## y.Cash_Flow_Rice_Pinang1  -2695.9 -2112.498 -1584.0 -2125.16      1.0000
## y.Cash_Flow_Rice_Pinang2   -101.2    51.174   184.7    46.67      0.2896
## y.Cash_Flow_Rice_Pinang3    284.4   506.325   758.0   511.02      0.0000
## y.Cash_Flow_Rice_Pinang4    178.3   435.356   708.8   438.98      0.0025
## y.Cash_Flow_Rice_Pinang5    240.6   511.265   814.1   517.41      0.0007
## y.Cash_Flow_Rice_Pinang6    281.5   578.193   897.0   580.91      0.0006
## y.Cash_Flow_Rice_Pinang7    329.4   627.255   965.4   635.94      0.0004
## y.Cash_Flow_Rice_Pinang8    357.4   667.934  1026.8   675.85      0.0001
## y.Cash_Flow_Rice_Pinang9    375.8   696.351  1061.0   703.45      0.0001
## y.Cash_Flow_Rice_Pinang10   265.0   598.004   975.8   606.24      0.0008
## y.Cash_Flow_Rice_Pinang11   411.8   740.055  1114.4   748.72      0.0003
## y.Cash_Flow_Rice_Pinang12   412.6   754.176  1138.7   761.82      0.0000
## y.Cash_Flow_Rice_Pinang13   424.7   765.174  1150.2   774.11      0.0000
## y.Cash_Flow_Rice_Pinang14   434.4   774.172  1157.0   782.59      0.0000
## y.Cash_Flow_Rice_Pinang15   441.1   780.783  1168.3   787.73      0.0000
## y.Cash_Flow_Rice_Pinang16   443.3   785.499  1168.2   793.56      0.0000
## y.Cash_Flow_Rice_Pinang17   440.0   791.851  1185.4   797.50      0.0000
## y.Cash_Flow_Rice_Pinang18   451.1   788.892  1185.8   800.35      0.0000
## y.Cash_Flow_Rice_Pinang19   451.9   796.526  1194.2   807.20      0.0000
## y.Cash_Flow_Rice_Pinang20   324.0   673.101  1070.5   682.12      0.0007
## y.Cash_Flow_Rice_Pinang21   448.8   800.309  1189.7   806.45      0.0001
## y.Cash_Flow_Rice_Pinang22   448.0   799.662  1191.4   805.55      0.0000
## y.Cash_Flow_Rice_Pinang23   456.9   796.350  1191.7   806.45      0.0001
## y.Cash_Flow_Rice_Pinang24   450.7   799.566  1193.7   808.28      0.0000
## y.Cash_Flow_Rice_Pinang25   455.5   804.022  1192.1   811.70      0.0000
##                           chance_zero chance_gain
## y.trade_off                         0      0.6626
## y.rice_pn_NPV                       0      0.9889
## y.rice_NPV                          0      0.6699
## y.Cash_Flow_Rice1                   0      0.1997
## y.Cash_Flow_Rice2                   0      0.7135
## y.Cash_Flow_Rice3                   0      0.7057
## y.Cash_Flow_Rice4                   0      0.7084
## y.Cash_Flow_Rice5                   0      0.6622
## y.Cash_Flow_Rice6                   0      0.7052
## y.Cash_Flow_Rice7                   0      0.6121
## y.Cash_Flow_Rice8                   0      0.7091
## y.Cash_Flow_Rice9                   0      0.6576
## y.Cash_Flow_Rice10                  0      0.4928
## y.Cash_Flow_Rice11                  0      0.7057
## y.Cash_Flow_Rice12                  0      0.7056
## y.Cash_Flow_Rice13                  0      0.5749
## y.Cash_Flow_Rice14                  0      0.7051
## y.Cash_Flow_Rice15                  0      0.6994
## y.Cash_Flow_Rice16                  0      0.7088
## y.Cash_Flow_Rice17                  0      0.6630
## y.Cash_Flow_Rice18                  0      0.7124
## y.Cash_Flow_Rice19                  0      0.6176
## y.Cash_Flow_Rice20                  0      0.4992
## y.Cash_Flow_Rice21                  0      0.6652
## y.Cash_Flow_Rice22                  0      0.7095
## y.Cash_Flow_Rice23                  0      0.7026
## y.Cash_Flow_Rice24                  0      0.7092
## y.Cash_Flow_Rice25                  0      0.5682
## y.Cash_Flow_Rice_Pinang1            0      0.0000
## y.Cash_Flow_Rice_Pinang2            0      0.7104
## y.Cash_Flow_Rice_Pinang3            0      1.0000
## y.Cash_Flow_Rice_Pinang4            0      0.9975
## y.Cash_Flow_Rice_Pinang5            0      0.9993
## y.Cash_Flow_Rice_Pinang6            0      0.9994
## y.Cash_Flow_Rice_Pinang7            0      0.9996
## y.Cash_Flow_Rice_Pinang8            0      0.9999
## y.Cash_Flow_Rice_Pinang9            0      0.9999
## y.Cash_Flow_Rice_Pinang10           0      0.9992
## y.Cash_Flow_Rice_Pinang11           0      0.9997
## y.Cash_Flow_Rice_Pinang12           0      1.0000
## y.Cash_Flow_Rice_Pinang13           0      1.0000
## y.Cash_Flow_Rice_Pinang14           0      1.0000
## y.Cash_Flow_Rice_Pinang15           0      1.0000
## y.Cash_Flow_Rice_Pinang16           0      1.0000
## y.Cash_Flow_Rice_Pinang17           0      1.0000
## y.Cash_Flow_Rice_Pinang18           0      1.0000
## y.Cash_Flow_Rice_Pinang19           0      1.0000
## y.Cash_Flow_Rice_Pinang20           0      0.9993
## y.Cash_Flow_Rice_Pinang21           0      0.9999
## y.Cash_Flow_Rice_Pinang22           0      1.0000
## y.Cash_Flow_Rice_Pinang23           0      0.9999
## y.Cash_Flow_Rice_Pinang24           0      1.0000
## y.Cash_Flow_Rice_Pinang25           0      1.0000

Expected Value of Perfect Information (EVPI)

Calculation EVPI

 # preparation EVPI
mcSimulation_table <- data.frame(mcSimulation_result1$x, mcSimulation_result1$y[1:3])

# calculation EVPI
evpi <- multi_EVPI(mc = mcSimulation_table, first_out_var = "trade_off")
## [1] "Processing 3 output variables. This can take some time."
## [1] "Output variable 1 (trade_off) completed."
## [1] "Output variable 2 (rice_ccpn_NPV) completed."
## [1] "Output variable 3 (rice_NPV) completed."
# plot EVPI
plot_evpi(evpi, decision_vars = "trade_off", base_size = 12)

# preparation EVPI
mcSimulation_table2 <- data.frame(mcSimulation_result2$x, mcSimulation_result2$y[1:3])

# calculation EVPI
evpi2 <- multi_EVPI(mc = mcSimulation_table2, first_out_var = "trade_off")
## [1] "Processing 3 output variables. This can take some time."
## [1] "Output variable 1 (trade_off) completed."
## [1] "Output variable 2 (rice_pn_NPV) completed."
## [1] "Output variable 3 (rice_NPV) completed."
# plot EVPI
plot_evpi(evpi2, decision_vars = "trade_off", base_size = 12)